<?xml version='1.0' encoding='ISO-8859-1' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:body>
        <ui:composition template="/templates/template.xhtml">
            <ui:define name="content">
                <b><h3><h:outputLabel value="Endre Oppgave" rendered="#{user.findRole()}"/></h3></b>
                <b><h3><h:outputLabel value="Denne siden har du ikke tilgang til!" rendered="#{not user.findRole()}"/></h3></b>
                <br/>
                <h:form>
                    <h:commandLink  action="../protected/taskAdministration.xhtml" rendered="#{user.findRole()}">Tilbake</h:commandLink>
                    <br/><br/><br/>
                    <b>Oppgavetekst:</b> <br/>
                    <h:inputTextarea id="textarea" style="width: 100%; height: 100px" value="#{tasks.storeTask.text}" >
                        <f:validateLength maximum="150"/>
                    </h:inputTextarea>
                    <h:message for="textarea" styleClass="errorMessage"/>
                    <br/><br/>
                    <b>Bilde:</b><br/>
                    <h:selectOneMenu value="#{tasks.imageNumber}" >
                        <f:selectItem itemValue="0" itemLabel="Ingen bilde" />
                        <f:selectItem itemValue="1" itemLabel="Fisk" />
                        <f:selectItem itemValue="2" itemLabel="Bil" />
                        <f:selectItem itemValue="3" itemLabel="Twitter fugl" />
                        <f:selectItem itemValue="4" itemLabel="Is" />
                        <f:selectItem itemValue="5" itemLabel="Iskrem" />
                        <f:selectItem itemValue="6" itemLabel="Terninger" />
                    </h:selectOneMenu>
                    <br/><br/>
                    <b>Legg til tall som skal brukes i regnestykket:</b><br/>
                    <br/>

                    <h:inputText value="#{tasks.newNumber}" />
                    <h:commandButton action="#{tasks.saveNewNumber}" value="Legg til"/>

                    <br/>
                    <h:dataTable value="#{tasks.storeTask.numbers}" var="name" styleClass="names2"
                                 headerClass="namesHeader" footerClass="namessFooter"
                                 rowClasses="last,first" rendered="#{user.findRole()}">
                        <h:column>
                            <f:facet name="header">Tall</f:facet>
                            <h:outputText value="#{name.number}"/>
                        </h:column>
                        <h:column>
                            <h:commandLink action="#{tasks.deleteNumber(name)}" >
                                <h:graphicImage title="Slett tall" value="../resources/images/delete.png" />
                            </h:commandLink>
                        </h:column>
                    </h:dataTable>
                    <br/><br/>
                    <b>En ukjent?</b><br/><h:selectBooleanCheckbox value="#{tasks.storeTask.isUnknown}">Ja</h:selectBooleanCheckbox>
                    <br/><br/>
                    <b>Svaralternativer?</b><br/><h:selectBooleanCheckbox onclick="submit()" value="#{tasks.storeTask.doHaveAlt}">Ja</h:selectBooleanCheckbox>
                    <br/><br/>
                    <b><h:outputLabel value="Alternativ 1:" rendered="#{tasks.storeTask.doHaveAlt}"/></b><h:inputText value="#{tasks.alt1}" rendered="#{tasks.storeTask.doHaveAlt}"></h:inputText><br/>
                    <b><h:outputLabel value="Alternativ 2:" rendered="#{tasks.storeTask.doHaveAlt}"/></b><h:inputText value="#{tasks.alt2}" rendered="#{tasks.storeTask.doHaveAlt}"></h:inputText><br/>
                    <b><h:outputLabel value="Alternativ 3:" rendered="#{tasks.storeTask.doHaveAlt}"/></b><h:inputText value="#{tasks.alt3}" rendered="#{tasks.storeTask.doHaveAlt}"></h:inputText>
                    <br/><br/>
                    <b><h:outputLabel value="Hvilket alternativ er riktig:" rendered="#{tasks.storeTask.doHaveAlt}"/></b>
                    <br/>
                    <h:selectOneMenu value="#{tasks.storeTask.answer}" rendered="#{tasks.storeTask.doHaveAlt}">
                        <f:selectItem itemValue="1" itemLabel="Alternativ 1" />
                        <f:selectItem itemValue="2" itemLabel="Alternativ 2" />
                        <f:selectItem itemValue="3" itemLabel="Alternativ 3" />
                    </h:selectOneMenu>

                    <b><h:outputLabel value="Svar:" rendered="#{not tasks.storeTask.doHaveAlt}"/></b>
                    <h:inputText value="#{tasks.storeTask.answer}" rendered="#{not tasks.storeTask.doHaveAlt}"></h:inputText>
                    <br/><br/>

                    <h:commandButton action="../protected/taskAdministration.xhtml" value="Avbryt"></h:commandButton>
                    <h:commandButton action="#{tasks.changeTask}" value="Lagre"></h:commandButton>
                </h:form>
            </ui:define>
        </ui:composition>
    </h:body>
</html>
